part of 'bar.dart';

class AppTabbarItem {
  AppTabbarItem({
    this.text,
    this.imagePath,
    this.activeImagePath,
    this.tip,
    this.color,
    this.activeColor,
  });
  final String? text;
  final String? imagePath;
  final String? activeImagePath;
  final String? tip;
  Color? color;
  Color? activeColor;
}

class _AppTabbarItem extends StatelessWidget {
  const _AppTabbarItem(
    this.item, {
    Key? key,
    this.onTap,
    this.isSelected = false,
  }) : super(key: key);
  final AppTabbarItem item;
  final VoidCallback? onTap;
  final bool isSelected;
  @override
  Widget build(BuildContext context) {
    var imagePath = isSelected ? item.activeImagePath : item.imagePath;
    var color = isSelected
        ? (item.activeColor ?? Colors.blue)
        : (item.color ?? const Color(0xff999999));
    return InkWell(
      onTap: onTap,
      child: Container(
        alignment: Alignment.center,
        child: Stack(
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                if (imagePath != null)
                  Image.asset(
                    imagePath,
                    width: 17,
                    height: 17,
                  ),
                if (imagePath != null && item.text != null)
                  const SizedBox(
                    height: 3,
                  ),
                if (item.text != null)
                  Text(
                    item.text!,
                    style: TextStyle(
                      color: color,
                      fontSize: 12,
                    ),
                  ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
